package com.itheima.mapper;

import com.itheima.pojo.Member;
import com.itheima.pojo.Order;
import com.itheima.pojo.dto.Order4SetmealCountDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    /**
     * 根据条件查询预约记录
     * @param queryString
     * @return
     */
    List<Order> selectByQueryString(String queryString);


    /**
     * 查询所有
     * @return
     */
    @Select("select * from `order`")
    List<Order> selectAll();

    /**
     * 更新预约信息
     * @param order
     */
    void update(Order order);

    /**
     * 查询预约套餐的数量
     * @return
     */
    @Select("select setmeal.name as name, sidcount.count as value from setmeal \n" +
            "inner join (select setmeal_id, count(*) as count from `order` group by setmeal_id) sidcount\n" +
            "on sidcount.setmeal_id = setmeal.id")
    List<Order4SetmealCountDto> getSetmealCount();

    /**
     * 查询预约套餐的数量
     * @return
     */
    @Select("select setmeal.name as name, sidcount.count as value from setmeal \n" +
            "inner join (select setmeal_id, count(*) as count from `order` group by setmeal_id) sidcount\n" +
            "on sidcount.setmeal_id = setmeal.id")
    List<Order4SetmealCountDto> getSetmealOrderData();
}
